#ifndef MY_FSM_H
#define MY_FSM_H

#include "State.h"

template <class Type>
class FSM
{
private:
	Type* mOwner;

	State<Type>* mCurrentState;
	State<Type>* mPreviousState;

public:
	FSM(Type* owner):mOwner(owner)
		,mCurrentState(NULL)
		,mPreviousState(NULL)
	{};


	void update()
	{
		mCurrentState->update(mOwner);
	}
	void changeState(State<Type>* newState)
	{
		mPreviousState = mCurrentState;
		mCurrentState->onExit(mOwner);
		mCurrentState = newState;
		mCurrentState->onEnter(mOwner);
	}


	//setter
	void setCurrentState(State<Type>* currState) {mCurrentState  = currState;}
	void setPreviousState(State<Type>* prevState){mPreviousState = prevState;}
	//getter
	const State<Type>* CurrentState() const {return mCurrentState;}
	const State<Type>* PreviousState()const {return mPreviousState;}
};

#endif //MY_FSM_H